package cn.wolfcode.luowowo.mgrsite.web;

import cn.wolfcode.luowowo.article.query.DestinationQuery;
import cn.wolfcode.luowowo.article.service.IDestinationService;
import cn.wolfcoe.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("destination")
public class DestinationController {


    @Reference
    private IDestinationService destinationService;


    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo") DestinationQuery qo) {

        //pageInfo
        model.addAttribute( "pageInfo", destinationService.query( qo ) );


        model.addAttribute( "toasts", destinationService.getToasts( qo.getParentId() ) );


        return "destination/list";

    }

    @RequestMapping("/changeHotValue")
    @ResponseBody
    public AjaxResult changeHotValue(Long id, boolean hot) {

        destinationService.updateHot( id, hot );

        return AjaxResult.SUCCESS;

    }


}
